﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SimFtp
{
    public partial class Form1 : Form
    {
        FTPLib.FTPHelper2 ftp;

        public Form1()
        {
            InitializeComponent();
            this.rtbLog.AppendText("Welcome!");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ftp = new FTPLib.FTPHelper2(this.textBox1.Text.Trim(), "", this.textBox2.Text.Trim(), this.textBox3.Text.Trim(), 21);

            if (ftp.Connect())
            {
                this.rtbLog.AppendText(ftp.Message);
                this.toolStripStatusLabel1.Text = "连接成功";
            }
            else
            {
                this.toolStripStatusLabel1.Text = ftp.Message;
                return;
            }
            string[] strFileList;
            if (ftp.Dir("", out strFileList))
            {
                for (int i = 0; i < strFileList.Length; i++)
                {
                    MessageBox.Show(strFileList[i].Split(' ')[2]);
                }
            }
            else
            {
                this.toolStripStatusLabel1.Text = ftp.Message;
                return;
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            ftp.DisConnect();
            this.toolStripStatusLabel1.Text = ftp.Message;
        }
    }
}
